package com.ruoyi.zhike.controller.account;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.zhike.db.domain.AccountInfo;
import com.ruoyi.zhike.account.service.IAccountInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.zhike.wrapper.AccountInfoWrapper;

/**
 * 总账户信息Controller
 * 
 * @author ruoyi
 * @date 2024-04-19
 */
@RestController
@RequestMapping("/account/accountInfo")
public class AccountInfoController extends BaseController
{
    @Autowired
    private IAccountInfoService accountInfoService;

    /**
    *
    */
    @GetMapping("/extData")
    public AjaxResult extData() {
        JSONObject returnData = new JSONObject();

        return AjaxResult.success(returnData);
    }

    /**
     * 查询总账户信息列表
     */
    @RequiresPermissions("account:accountInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(AccountInfo accountInfo)
    {
        startPage();
        List<Map<String, Object>> list = accountInfoService.selectAccountInfoListMap(accountInfo);
        list = new AccountInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出总账户信息列表
     */
    @RequiresPermissions("account:accountInfo:export")
    @Log(title = "总账户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AccountInfo accountInfo)
    {
        List<AccountInfo> list = accountInfoService.selectAccountInfoList(accountInfo);
        ExcelUtil<AccountInfo> util = new ExcelUtil<AccountInfo>(AccountInfo.class);
        util.exportExcel(response, list, "总账户信息数据");
    }

    /**
     * 获取总账户信息详细信息
     */
    @RequiresPermissions("account:accountInfo:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(accountInfoService.selectAccountInfoById(id));
    }

    /**
     * 新增总账户信息
     */
    @RequiresPermissions("account:accountInfo:add")
    @Log(title = "总账户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AccountInfo accountInfo)
    {
        return toAjax(accountInfoService.insertAccountInfo(accountInfo));
    }

    /**
     * 修改总账户信息
     */
    @RequiresPermissions("account:accountInfo:edit")
    @Log(title = "总账户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AccountInfo accountInfo)
    {
        return toAjax(accountInfoService.updateAccountInfo(accountInfo));
    }

    /**
     * 删除总账户信息
     */
    @RequiresPermissions("account:accountInfo:remove")
    @Log(title = "总账户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(accountInfoService.deleteAccountInfoByIds(ids));
    }
}
